<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        .AS{
            color: red;
        }
    </style>
</head>
<body>
    <table border="1" cellpadding=0 cellspacing=0 id="igon">

    </table>
    <script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>
    <script>
        var tableTitle = ['小树苗', '任宝茹', '任宝双'];
        var tableItem = [
            {
                time: '2020-01-05 21:44:20',
                num: {
                    data: 400,
                    color: true
                }
            },
            {
                time: '2020-01-06 21:44:20',
                num: {
                    data: 500,
                    color: true
                }
            },
            {
                time: '2020-01-08 21:44:20',
                num: {
                    data: 600,
                    color: false
                }
            }
        ]
        var options = '<tr>'+ '<th>'+'项目'+'</th>';
        for(i=0; i < tableItem.length; i++){
            options += '<th>' + tableItem[i].time + '</th>';
        }
        options += '</tr>';
        var opt = '<tr>';
        for(j=0; j < tableTitle.length; j++){
            opt += '<th class="ax">'+ tableTitle[j] + '</th>'+'</tr>';
        }
        for(x=0; x < tableItem.length; x++){
            // opt += '<th>' + tableItem[x].num.data + '</th>';
        }
        // opt += '</tr>';
        $('#igon').append(options);
        $('#igon').append(opt);
        var as = [];
        as = tableItem.reverse();
        $('.ax').each(function(e){
            console.log(e)
            console.log($(this).eq(e).text())
            for(x=0; x < as.length; x++){
                console.log(as[x].num.data)
                console.log(as[x].num.color)
                // opt += '<th>' + tableItem[x].num.data + '</th>';
                $(this).after('<th class="as[x].num.color==true? AS : " "">' + as[x].num.data + '</th>')
            }
        })
    </script>
</body>
</html>